<template>
	<view class="page" :style="{height:windowHeight+'px'}">
		<view class="titles">
			<text class="title">
				安全保障
			</text>
			<text class="sub-title">
				操作简单 ● 方便快捷
			</text>
		</view>

		<image class="image" src="https://iyouhaolife-1316622368.cos.ap-chongqing.myqcloud.com/h5/static/download.png" mode="widthFix"></image>

		<view class="btns">
			<view class="down" @click="download">
				立即下载
			</view>
			<view class="h5" @click="h5">
				继续使用
			</view>
		</view>

	</view>
</template>

<script>
	import http from "@/common/http.js"



	function isWeiXin() {

		var ua = window.navigator.userAgent.toLowerCase();
		if (ua.match(/MicroMessenger/i) == 'micromessenger') {
			return true;
		} else {
			return false;
		}
	}

	export default {
		data() {
			return {
				windowHeight: 0,
				url:'',
			}
		},
		onLoad() {
			this.windowHeight = uni.getSystemInfoSync().windowHeight
			this.getUrl();
		},
		methods: {
			getUrl() {
				http.request({
					url: '/api/v1/getSysDic',
					data:{
						key:'downloadUrl'
					},
					success: ret => {
						console.log(ret);
						this.url = ret[0].dicValue
					},
					fail:ret=>{
						uni.showToast({
							icon:"none",
							title:'获取下载地址失败'
						})
					}
				})
			},
			download(){
				if(isWeiXin()){
					uni.showModal({
						showCancel:false,
						title:'请使用浏览器打开'
					})
				}else{
					console.log(this.url)
					if(this.url){
						window.location.href = this.url;
					}
					
				}
			},
			h5(){
				uni.reLaunch({
					url: 'login'
				})
			}
		}
	}
</script>

<style lang="scss">
	.page {
		background-image: linear-gradient(#8bc0f7, #4281f7);
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-around;
		padding: 45rpx 0;
		box-sizing: border-box;

		.titles {
			display: flex;
			flex-direction: column;
			align-items: center;

			.title {
				font-family: Microsoft YaHei;
				font-size: 35px;
				font-weight: 400;
				color: #FFFFFF;
			}

			.sub-title {
				margin-top: 18rpx;
				font-size: 18px;
				font-family: Microsoft YaHei;
				font-weight: 400;
				color: #FFFFFF;
			}
		}

		.image {
			width: 252rpx;
		}

		.btns {
			.down {
				display: flex;
				align-items: center;
				justify-content: center;
				border-radius: 100rpx;
				width: 560rpx;
				height: 100rpx;
				background: #FEFFFF;
				font-size: 36rpx;
				font-family: Microsoft YaHei;
				font-weight: 800;
				color: #000000;
			}

			.h5 {
				margin-top: 21rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 36rpx;
				font-family: Microsoft YaHei;
				font-weight: 800;
				color: #C4DFFA;
			}
		}

	}
</style>
